#ifndef TDOWNLAD_H
#define TDOWNLAD_H

#include <QString>
#include <QThread>
#include <QWidget>
#include <QDialog>
#include <QHttp>
#include <QUrl>

QT_BEGIN_NAMESPACE
class QDialogButtonBox;
class QFile;
class QLabel;
class QLineEdit;
class QProgressDialog;
class QPushButton;
class QSslError;
class QAuthenticator;
class QNetworkReply;

class TDownlad : public QThread
{
    Q_OBJECT
    QUrl        url;
    bool        httpRequestAborted;
    QString     path;
    QString     hash;
    QFile       *file;
    QHttp       *http;
    int         reply;
    bool        finish;
private:
    QString CalcSha1(QString Path);
public:
    //explicit TDownlad(QObject *parent = 0);
    explicit TDownlad(QObject *parent, QString url);
    TDownlad(QObject *parent, QString url, QString hash);
    ~TDownlad(){qDebug("thread destruction");}
    void run();
    void startRequest   (QUrl url);

signals:
    void updateProgress(int, int);
    void updateSl(QString);
    void done();
    void sdlerror();
public slots:
    void httpFinished(int, bool);
    void httpReadyRead();
    void downloadProgress(int, int);

};

#endif // TDOWNLAD_H
